<%@ page import="java.util.List" %>

<%@ taglib uri="/WEB-INF/bpmapp.tld" prefix="ssp" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>

<% String ctPath = request.getContextPath(); %>

<div class="blockTitle">
   <span class="left">
     <bean:message bundle="appCommonRes" key="bp.alerts.alertInbox" />
   </span>
   <span class="right">&nbsp;</span>
</div>
<div class="blockWrap">
    <table width="100%" class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Task Inbox">

      <tr class="listHeader">
        <th id="Subject" align="left">
          <bean:message bundle="appCommonRes" key="bp.alerts.subject" />
        </th>
        <th id="Received" align="left">
          <bean:message bundle="appCommonRes" key="bp.alerts.received" />
        </th>
        <th id="Action" align="left">
          <bean:message bundle="appCommonRes" key="bp.alerts.action" />
        </th>
      </tr>


<ssp:queryAlert id="alertList" type="all" displayType="HOME_PAGE_INBOX" maxReturn="5"/>

<logic:iterate id="alertItem" name="alertList" length="5" indexId="index">

      <tr class="<%=index.intValue() % 2 == 0? "listEven" : "listOdd" %>" >

        <td headers="Subject">
          <a href = "<bean:write name='alertItem' property ='viewURL' />" >
            <bean:write name="alertItem" property = "subject" />
          </a>
        </td>

        <td headers="Received">
          <bean:write name="alertItem" property ="creationDate" formatKey="format.datetime.short" />
        </td>

        <td headers="Action">
          <a href = "<bean:write name='alertItem' property = 'deleteURL' /> ">
            <html:img page="/ca/images/action/icon_delete.gif" styleClass="actionIcon" border="0" altKey="button.delete" titleKey="button.delete"/>
          </a>

        </td>
      </tr>
</logic:iterate>

      <% 
         int numAlerts = ((List)pageContext.getAttribute("alertList")).size();
         int maxToDisplay = 5;

         if (numAlerts <= 0)
         {
      %>
      <tr class="listOdd">
        <td colspan="3" align="center">
        <bean:message bundle="appCommonRes" key="bp.alerts.noAlerts" />
        </td>
      </tr>

      <% 
         }
         else if ( numAlerts >= maxToDisplay) 
         { 
      %>

      <tr class="listOdd">
        <td colspan="3"> <br>
	<bean:message bundle="appCommonRes" key="show.no.of.all" arg0="<%=Integer.toString(maxToDisplay)%>" arg1="<%=Integer.toString(numAlerts)%>"/>&nbsp; &nbsp;
          <html:link page="/ca/allAlerts.do">
            <bean:message bundle="appCommonRes" key="view.all" />
          </html:link>
        </td>
      </tr>
  
      <% 
        } 
      %>


    </table>
</div>